package com.dingreading.cloud.soms.controller;

import com.dingreading.cloud.common.base.R;
import com.dingreading.cloud.common.util.PageUtil;
import com.dingreading.cloud.soms.service.StoreFunctionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/front/storeFunction")
@Api(tags = "门店-门店个性化功能")
public class FrontStoreFunctionController {

    @Resource
    private StoreFunctionService storeFunctionService;

    @ApiOperation(value = "分页列表")
    @PostMapping(value = "/pageList", produces = "application/json; charset=UTF-8")
    public R<Object> pageList(
            @ApiParam(value = "分页公共类") PageUtil pageUtil,
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "门店名称") @RequestParam(value = "storeName") String storeName,
            @ApiParam(value = "员工uid") @RequestParam(value = "staffUid") String staffUid,
            @ApiParam(value = "员工名") @RequestParam(value = "staffName") String staffName,
            @ApiParam(value = "功能名称") @RequestParam(value = "keyword", required = false) String keyword,
            @ApiParam(value = "默认状态(0.关闭，1.开启)") @RequestParam(value = "status", required = false) Integer status
    ) {
        return storeFunctionService.pageList(pageUtil, corpUid, storeUid, storeName, staffUid, staffName, keyword, status);
    }


    @ApiOperation(value = "更新功能开启状态")
    @PostMapping(value = "/updateStatus", produces = "application/json; charset=UTF-8")
    public R<Object> updateStatus(
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "门店名称") @RequestParam(value = "storeName") String storeName,
            @ApiParam(value = "员工uid") @RequestParam(value = "staffUid") String staffUid,
            @ApiParam(value = "员工名") @RequestParam(value = "staffName") String staffName,
            @ApiParam(value = "功能uid") @RequestParam(value = "uid") String uid,
            @ApiParam(value = "功能是否开启状态 0.禁用 1.启用") @RequestParam(value = "status") Integer status
    ) {
        return storeFunctionService.updateStatus(corpUid, storeUid, storeName, staffUid, staffName, uid, status);
    }

}
